import { request } from "../../utils/request";
Page({
  data: {
    startList: [],
    useInfo: {},
  },

  /**
   * 生命周期函数--监听页面加载
   */
  async onLoad() {
    let StartDataList = await request("/start");
    let userInfo = wx.getStorageSync("userInfo");
    if (userInfo) {
      // 更新userInfo的状态
      this.setData({
        userInfo: userInfo,
      });
    }
    this.setData({
      startList: StartDataList.data,
    });
  },
  toSongDetail(e) {
    let index = e.currentTarget.dataset.index;
    let currentMusic = this.data.startList[index];
    wx.navigateTo({
      url: "/pages/songDetail/songDetail",
      success: function (res) {
        res.eventChannel.emit("detail", { musicData: currentMusic });
      },
    });
  },
});
